package grp.test.controller;

import grp.test.pojo.Borrow;
import grp.test.pojo.BorrowKey;
import grp.test.service.IReturnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
@Controller
@RequestMapping("/return/")
public class IReturnController {
    @Autowired
    private IReturnService iReturnService;
    @RequestMapping(value = "getBorrowInformation.do",method = RequestMethod.POST)
    @ResponseBody
    //查询
    public Borrow searchBorrowInformation(Integer userId,Integer bookId)
    {
        BorrowKey key = new BorrowKey(userId,bookId);
        Borrow obj = iReturnService.getBorrowInformation(key);
        if (obj==null)
        {
            return null;
        }
        else
            return obj;
    }

    //还书
    @RequestMapping(value = "returnBook.do",method = RequestMethod.POST)
    @ResponseBody
    public List<String> ReturnBook(Integer bookId,Integer userId)
    {
        List<String> lst = iReturnService.ReturnBook(bookId,userId);
        return lst;
    }
}
